<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
	    <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
        <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
        <link rel="stylesheet" type="text/css" href="easyui/themes/color.css">
        <script type="text/javascript" src="easyui/jquery.min.js"></script>
        <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
        <link rel="stylesheet" href="layui/css/layui.css" media="all">
        <script type="text/javascript" src="layui/layui.all.js"></script>
    </head>
    <body>
         <table id="dat" class="easyui-datagrid" title="表数据" data-options="fit:true,singleSelect:false,
                                                                   selectOnCheck:true,ctrlSelect:true,
                                                                   fitColumns:true,rownumbers:true,
                                                                   collapsible:true,
                                                                   url:'sys/data/tables',
                                                                   method:'post',toolbar:toolbars">
	        <thead>
	            <tr>
	                <th data-options="field:'table_schema',width:100">库名称</th>
	                <th data-options="field:'table_name',width:100">表名称</th>
	                <th data-options="field:'table_type',width:110">表类型</th>
	                <th data-options="field:'engine',width:100">引擎</th>
	                <th data-options="field:'table_rows',width:180">行数</th>
	                <th data-options="field:'data_length',width:180">数据量</th>
	                <th data-options="field:'table_collation',width:120">编码</th>
	                <th data-options="field:'table_comment',width:250">备注</th>
	                <th data-options="field:'create_time',width:180">创建时间</th>
	                <th data-options="field:'update_time',width:180">修改时间</th>
	            </tr>
	        </thead>
	    </table>
    </body>
    <script type="text/javascript">
		    var toolbars = [{
		        text:'开始生成',
		        iconCls:'icon-add',
		        handler:function(){
		        	var data=$('#dat').datagrid('getSelections');
		        	if(data&&data.length>0){
		        		var tables=[];
		        		for(var i in data){
		        			tables.push(data[i]['table_name']);
		        		}
		        		if(tables.length>0){
		        			console.log(tables);
		        			$.post('sys/data/gencode',{'tables':tables},function(r){
		        				console.log(r);
		        			})
		        		}
		        	}else{
		        		layer.alert('请选择要生成的表结构');
		        	}
		        }
		    }];
		    
    </script>
</html>